%pylab inline
#import matplotlib.pyplot as plt
from ipywidgets import *
A vizcseppen belüli sugármenetek rajzolása
# a szinekhez tartozo toroesmutatok:
nred = 1.33; ngreen = 1.335; nblue = 1.34;
# 'r' ---> red, 'g' ---> green, 'b' ---> blue
nszinek = {"r":nred, "g":ngreen, "b":nblue} # dictionary type variable
nszinek['b']
# A Descartes-sugarhoz tartozo kritikus bc impaktparameter szamolasa
# p = a hurok szama a vizcseppen belul, n = a toresmutato
def bc(p, n):
tmp=sqrt((p*p - n*n)/(p*p - 1));
return(tmp)
bc(2,nred)
# Az abra kimentesehez az alabbiakat a plt.show() ele kell tenni!!!
#savefig('fig_rainbow_p2_1ray.pdf'); # Abra kimentese
#savefig('fig_rainbow_p2_1ray.eps'); # Abra kimentese
# Egy sugarmenet rajzolasa adott (bimpact,phur,ntores, szin) parameterek mellett.
#
# bimpact = a bemeno fenysugar impakt parametere, 0 < bimpact < 1,
# phur = hurok szama a vizcseppen belul,
# ntores = toresmutato,
# szin = a fenysugar szine a rajzon.
def rainbowray_rajz(bimpact,phur,ntores,szin):
#plt.figure()
figsize(10,10)
#ax=subplot(aspect='equal')
alpha=arcsin(bimpact)
beta=arcsin(bimpact/ntores)
fi=[];
for i in range(0,phur+1):
fi.append(pi-(alpha+i*(pi-2*beta)))
x=cos(fi)
y=sin(fi)
t = np.arange(0.0, 2.0*pi, 0.01)
plot(cos(t), sin(t), color='k', lw=3)
plot(x,y,color=szin,lw=2)
#arrow( x, y, dx, dy, **kwargs )
#bemeno fenysugar
nyilbe=1
xbe=(nyilbe+cos(alpha))
ybe=sin(alpha)
x1=-xbe+0.5*nyilbe
witdh_nyil = 0.09 # 0.03 volt
length_nyil = 0.09 # 0.09 volt
arrow(-xbe,ybe,0.5*nyilbe,0,
head_width=witdh_nyil, head_length=length_nyil, fc=szin, ec=szin,lw=2)
arrow(x1,ybe,-x1-cos(alpha),0,
head_width=0, head_length=0, fc=szin, ec=szin,lw=2)
#kimeno fenysugar
fimax=fi[phur]
xki=cos(fimax)
yki=sin(fimax)
nyilki=1.5
arrow(xki,yki,nyilki*cos(-alpha+fimax),nyilki*sin(-alpha+fimax),
head_width=witdh_nyil, head_length=length_nyil, fc=szin, ec=szin,lw=2)
xlim(-2.5,2.5)
ylim(-2.5,2.5)
axis('off')
return ()
# Tobb sugarmenet rajzolasa adott (nn, phur, ntores, szin) parameterek mellett,
#
# nn = a vizcseppre bemeno parhuzamos fenysugarak szama,
# phur = hurok szama a vizcseppen belul,
# ntores = toresmutato,
# szin = a fenysugar szine a rajzon.
def rainbowray_rajz_multi(nn,phur,ntores,szin):
for j in range(0,abs(nn)):
alpha=j*pi/2/nn
bb=sin(alpha)
rainbowray_rajz(bb,phur,ntores,szin)
gca().set_aspect('equal')
return()
# Egy bejovo fenysugar kulonbozo impakt parameterrel (piros szinnel)
@interact(b=(0,1,.01),phur=(0,17,1))
def play(b=0.8,phur=2):
rainbowray_rajz(b,phur,nred,'r');
#plt.show()
# A bejovo parhuzamos fenysugarak (piros szinnel)
@interact(nn=(0,57,1),phur=(0,17,1))
def play(nn=5,phur=2):
rainbowray_rajz_multi(nn,phur,nred,'r')
#rainbowray_rajz(bc(phur,nred),phur,nred,'b')
#plt.show()
# A bejovo parhuzamos fenysugarak (piros szinnel, nn darab)
# es a Descartes sugarak (kek szinnel) egyutt
@interact(nn=(1,57,1),phur=(2,17,1))
def play(nn=5,phur=2):
rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(bc(phur,nred),phur,nred,'b');
#plt.show()
# Egy-egy, kulonbozo szinu bejovo fenysugar adott impakt parameterrel
@interact(b=(-1,1,.01),phur=(0,17,1))
def play(b=0.5,phur=2):
rainbowray_rajz(b,phur,ngreen,'g')
rainbowray_rajz(b,phur,nblue,'b')
rainbowray_rajz(b,phur,nred,'r');
#rainbowray_rajz(bc(phur,nred),phur,nred,'b')
#plt.show()
# Descartes sugarak kulonbozo szinu fenysugarakra
pp=17; # a hurok szama a vizcseppen belul
rainbowray_rajz(-bc(pp,nred),pp,nred,'r')
rainbowray_rajz(-bc(pp,ngreen),pp,ngreen,'g')
rainbowray_rajz(-bc(pp,nblue),pp,nblue,'b');
#plt.show()
phur=2;
bin= bc(phur,nred)
#rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(bin,phur,nred,'r');
#savefig('fig_rainbow_p2_1ray.pdf'); # Abra kimentese
#savefig('fig_rainbow_p2_1ray.eps'); # Abra kimentese
#plt.show();
phur=2;
nn=17;
rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(bc(phur,nred),phur,nred,'b');
#savefig('fig_rainbow_p2.pdf'); # Abra kimentese
#savefig('fig_rainbow_p2.eps'); # Abra kimentese
plt.show();
phur=3;
bin= - bc(phur,nred)
#rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(bin,phur,nred,'r');
#savefig('fig_rainbow_p3_1ray.pdf'); # Abra kimentese
savefig('fig_rainbow_p3_1ray.eps'); # Abra kimentese
#plt.show();
bin2= bc(2,nred)
bin3= -bc(3,nred)
#rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(bin2,2,nred,'r')
rainbowray_rajz(bin3,3,ngreen,'g');
#savefig('fig_rainbow_p2_1ray.pdf'); # Abra kimentese
#savefig('fig_rainbow_p2_1ray.eps'); # Abra kimentese
#plt.show();
phur=3;
nn=-17;
rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(-bc(phur,nred),phur,nred,'b');
#savefig('fig_rainbow_p3.df')
#savefig(, bbox_inches = 'tight', pad_inches = 0)
#savefig('fig_rainbow_p3.png',bbox_inches='tight', pad_inches=0); # Abra kimentese
#savefig('fig_rainbow_p3.eps'); # Abra kimentese
#plt.show()
phur=3;
nn=-17;
rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(-bc(phur,nred),phur,nred,'b');
#plt.show()
phur=4;
nn=-17;
rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(-bc(phur,nred),phur,nred,'b');
#plt.show()
phur=5;
nn=17;
rainbowray_rajz_multi(nn,phur,nred,'r')
rainbowray_rajz(bc(phur,nred),phur,nred,'b');
#plt.show()
# Az elterules szoge a b impakt parameter fuggvenyeben, adott p es ntores toresmutato eseten
def theta(b,p,ntores):
x=(p-1)*pi + 2*arcsin(b) - 2*p*arcsin(b/ntores)
theta=arccos(cos(x))*180/pi # az elterules szoge fokban
return(theta)
theta(.1,2,nred)
theta(bc(2,nred),2,nred)
x=linspace(0,1,200)
figsize(8,8)
plt.text(.2, 135,r'$p=0$',fontsize=24)
plt.text(.6, 30,r'$p=1$',fontsize=24)
plt.text(.6, 150,r'$p=2$',fontsize=24)
plt.text(.2, 50,r'$p=3$',fontsize=24)
plot(x,theta(x,0,nred), color='k')
plot(x,theta(x,1,nred), color='r')
plot(x,theta(x,2,nred), color='g')
plot(x,theta(x,3,nred), color='b')
#plot(x,theta(x,5,nred), color='b')
plt.show()
ntores=nred;
phurmax=17;
tt=[];
bbc=[];
for i in range(2,phurmax+1):
tt.append([i,theta(bc(i,ntores),i,ntores)])
bbc.append([i,bc(i,ntores)])
print(tt)
print()
print(bbc)
len(tt)
tt[0][1]
tt[len(tt)-1][0]
nszinek['r']
szin='r' # 'r' ---> red, 'g' ---> green, 'b' ---> blue
ntores = nszinek[szin]
phurmax = 17;
tt=[];
bbc=[];
for i in range(2,phurmax+1):
tt.append([i,theta(bc(i,ntores),i,ntores)])
bbc.append([i,bc(i,ntores)])
print(tt)
print()
print(bbc)
figsize(12,12)
ax=subplot(aspect='equal')
imin=2;
imax=tt[len(tt)-1][0]-1;
#imin = 3
#imax = 5
for i in range(0,imax):
szog=pi/180*tt[i][1];
sc=0.8;
xveg=sc*cos(szog)
yveg=-sc*sin(szog)
pp=tt[i][0]
textout= '$p =$' + str(pp)
arrow(0,0,xveg,yveg,head_width=0.03,
head_length=0.05, fc=szin, ec=szin,lw=2)
scale=1.15
text(xveg*scale,yveg*scale, textout)
xlim(-1,1)
ylim(-1,0)
plt.show()
szin='r' # 'r' ---> red, 'g' ---> green, 'b' ---> blue
ntores = nszinek[szin]
phurmax=17;
tt=[];
ttfok=[];
bbc=[];
for i in range(2,phurmax+1):
tt.append([i,theta(bc(i,ntores),i,ntores)])
ttfok.append([i,180-theta(bc(i,ntores),i,ntores)])
bbc.append([i,bc(i,ntores)])
print(ttfok)
#print()
#print(bbc)
figsize(12,12)
ax=subplot(aspect='equal')
imin=2;
imax=tt[len(tt)-1][0]-1;
#imin = 3
#imax = 5
for i in range(0,imax):
szog=pi/180*(180-tt[i][1]);
sc=0.8;
xveg=sc*cos(szog)
yveg=sc*sin(szog)
pp=tt[i][0]
textout= '$p =$' + str(pp)
arrow(0,0,xveg,yveg,head_width=0.03,
head_length=0.05, fc=szin, ec=szin,lw=2)
scale=1.15
text(xveg*scale,yveg*scale, textout)
xlim(-1,1)
ylim(0,1)
plt.show()
szin='r' # 'r' ---> red, 'g' ---> green, 'b' ---> blue
ntores = nszinek[szin]
phurmax = 4;
tt=[];
bbc=[];
for i in range(2,phurmax+1):
tt.append([i,theta(bc(i,ntores),i,ntores)])
bbc.append([i,bc(i,ntores)])
figsize(12,12)
ax=subplot(aspect='equal')
imin=2;
imax=tt[len(tt)-1][0]-1;
for i in range(0,imax):
szog=pi/180*(180-tt[i][1]);
sc=0.8;
xveg=sc*cos(szog)
yveg=sc*sin(szog)
pp=tt[i][0]
textout= '$p =$' + str(pp)
arrow(0,0,xveg,yveg,head_width=0.03,
head_length=0.05, fc=szin, ec=szin,lw=2)
scale=1.15
text(xveg*scale,yveg*scale, textout)
szin='b' # 'r' ---> red, 'g' ---> green, 'b' ---> blue
ntores = nszinek[szin]
tt=[];
bbc=[];
for i in range(2,phurmax+1):
tt.append([i,theta(bc(i,ntores),i,ntores)])
bbc.append([i,bc(i,ntores)])
imin=2;
imax=tt[len(tt)-1][0]-1;
for i in range(0,imax):
szog=pi/180*(180-tt[i][1]);
sc=0.8;
xveg=sc*cos(szog)
yveg=sc*sin(szog)
pp=tt[i][0]
textout= '$p =$' + str(pp)
arrow(0,0,xveg,yveg,head_width=0.03,
head_length=0.05, fc=szin, ec=szin,lw=2)
scale=1.15
text(xveg*scale,yveg*scale, textout)
xlim(-1,1)
ylim(0,1)
plt.show()